<template>
  <div>
    <!-- <a-form v-if="find" @submit="handleSubmit" :form="form" style="width:40%;;margin:0 auto;">
      <a-form-item v-bind="formItemLayout" label="当前支付密码">
        <div>
          <a-input
            class="input-width"
            placeholder="请输入当前支付密码"
            v-decorator="[
                        'currentpaypwd',
                        {
                            rules: [{
                            required: true, message: '请输入当前支付密码',
                            },{ validator: validateToNextpayword }
                            ],validateTrigger: 'blur'
                        }
                        ]"
            type="password"
          />
          <span style="color:#40a9ff;font-size:12px;" @click="forget">忘记支付密码</span>
        </div>
      </a-form-item>
      <div v-if="forgetshow" style="width:400px;margin:0 auto;">
        <div class="type">
          <span class="span-wid">通过“手机验证+回答安全密保问题”找回</span>
          <a-button type="primary" class="but-sty" @click="gomodify(1)">立即重置</a-button>
        </div>
        <div class="type">
          <span class="span-wid">通过“手机验证”找回</span>
          <a-button type="primary" class="but-sty" @click="gomodify(2)">立即重置</a-button>
        </div>
      </div>

      <a-form-item v-bind="formItemLayout" label="新支付密码" help="支付密码为6位纯数字密码">
        <a-input
          class="input-width"
          placeholder="请输入新支付密码"
          v-decorator="[
                        'paypwd',
                        {
                            rules: [{
                            required: true, message: '请输入新支付密码',
                            },{ validator: validateToNextpayword }
                            ],validateTrigger: 'blur'
                        }
                        ]"
          type="password"
        />
      </a-form-item>
      <a-form-item v-bind="formItemLayout" label="确认新支付密码">
        <a-input
          class="input-width"
          placeholder="确认新支付密码"
          v-decorator="[
                        'paypwdagain',
                        {
                            rules: [{
                            required: true, message: '确认新支付密码',
                            }, {
                            validator: compareToFirstpayword,
                            }],validateTrigger: 'blur'
                        }
                        ]"
          type="password"
        />
      </a-form-item>
      <div style="text-align:center;">
        <a-button size="large" htmlType="submit" type="primary">确定</a-button>
      </div>
    </a-form> -->
    <!-- <router-view v-if="!find"></router-view> -->
    <router-view></router-view>
haaaaaaaaaaaaaaaaaaaa
    <a-modal title="支付密码重置成功！" v-model="visible" :footer="null">
      <div style="text-align:center;">
        <!-- <a-button type="primary" @click="gologin">重新登录</a-button> -->
        <a-button type="primary" @click="gologin">确定</a-button>
      </div>
    </a-modal>
  </div>
</template>

<script>
import AForm from "ant-design-vue/es/form/Form";
import ATabs from "ant-design-vue/es/tabs";
// import GlobalFooter from "../../layouts/GlobalFooter";
import AFormItem from "ant-design-vue/es/form/FormItem";
import AInput from "ant-design-vue/es/input/Input";
import AIcon from "ant-design-vue/es/icon";
import AInputGroup from "ant-design-vue/es/input/Group";
import AButton from "ant-design-vue/es/button/button";
import ACol from "ant-design-vue/es/grid/Col";
import ARow from "ant-design-vue/es/grid/Row";
import ACheckbox from "ant-design-vue/es/checkbox/Checkbox";
import AAlert from "ant-design-vue/es/alert/index";
import api from "@/common/api";
import { get, post } from "@/common/api";

const ATabPane = ATabs.TabPane;

export default {
  name: "Login",
  components: {
    AAlert,
    ACheckbox,
    ACol,
    ARow,
    AButton,
    AInputGroup,
    AIcon,
    AInput,
    AFormItem,
    // GlobalFooter,
    ATabPane,
    ATabs,
    AForm
  },
  data() {
    return {
      visible: false,
      find:true,
      form: this.$form.createForm(this),
      error: "",
      forgetshow: false,
      currentpaypwd: "",
      paypwdagain: "",
      login: false,
      formItemLayout: {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 7 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
          md: { span: 14 }
        }
      }
    };
  },
  watch: {},
  computed: {},
  mounted() {},
  methods: {
    handleChange(value) {
      console.log(value);
    },
    handleSubmit(e) {
      e.preventDefault();
      this.form.validateFields((err, values) => {
        if (!err) {
          this.visible = true;
          console.log("Received values of form: ", values);
          //   this.codeConfirm();
        }
      });
    },
    // 支付密码验证
    validateToNextpayword(rule, value, callback) {
      const form = this.form;
      const reg = new RegExp("^[0-9]{6}$");
      if (value && !reg.test(value)) {
        // form.validateFields(['confirm'], { force: true });
        callback("您输入支付密码的格式有误！");
      } else {
        console.log("支付密码", value);
        this.currentpaypwd = value;
      }
      callback();
    },
    compareToFirstpayword(rule, value, callback) {
      const form = this.form;
      if (value && value !== form.getFieldValue("paypwd")) {
        callback("两次输入的支付密码不一致!");
      } else {
        callback();
      }
    },

    gologin() {
      this.visible = false;
      //   this.$router.push("/home");
    },
    gomodify(value){
       this.find = false;
        this.$router.push("/org/safeset/modifypaypw" + value);
    },
    forget() {
      this.forgetshow = !this.forgetshow;
    }
  }
};
</script>

<style lang="less" scoped>
span {
  cursor: pointer;
}
.type {
  padding: 5px;
  background: #eee;
  margin-bottom: 10px;
}
.input-width {
  width: 70%;
}
.span-wid {
  width: 300px;
  display: inline-block;
  font-size: 13px;
}
.but-sty {
  font-size: 12px;
  padding: 0px 10px;
  height: 28px;
}
</style>
